<?php
namespace DesignModel;

//单例模式

//场景 比如数据链接 使用单例模式 避免new 很多数据库链接浪费数据库资源
class Database
{

    protected static $db;

    //声明一个静态的方法获取数据链接对象
    public static function getInstance()
    {
        if (isset(self::$db)) {
            return self::$db;
        }else{
            self::$db= new self();
            return self::$db;
        }
    }

    public function where($where)
    {
        return $this;
    }

    public function page($index, $size)
    {
        return $this;
    }

    public function order($field, $order)
    {
        return $this;
    }

    public function select()
    {
        return $this;
    }
}
//$db=new Database();
//var_dump($db);
//$db= Database::getInstance();
//$db= Database::getInstance();
//$db= Database::getInstance();
//$db= Database::getInstance();
//$db= Database::getInstance();
//$db= Database::getInstance();
//var_dump($db);